package com.jbp.controller;

import com.jbp.model.VisitorLog;
import com.jbp.service.VisitorLogService;
import com.jbp.utils.PageUtils;
import com.jbp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 访客记录(VisitorLog)表控制层
 * @author cc
 * @since 2020-06-21 22:46:33
 */
@Api(tags ="APP接口--访客记录" )
@RestController
@RequestMapping("rest/visitorLog")
public class VisitorLogController {
    @Autowired
    private VisitorLogService visitorLogService;

    /** 访问记录 我看别人 */
    @ApiOperation(value="访问记录 我看别人")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = VisitorLog.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/list")
    public R list(@RequestAttribute("userId") Integer userId, @RequestParam Map<String, Object> params){
        params.put("userId",userId);
        PageUtils page = visitorLogService.queryPage(params);
        return R.ok().put("page", page);
    }

    /** 来访记录 别人看我*/
    @ApiOperation(value="来访记录 别人看我")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = VisitorLog.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/whoVisitMe")
    public R whoVisitMe(@RequestAttribute("userId") Integer userId, @RequestParam Map<String, Object> params){
        params.put("userId",userId);
        PageUtils page = visitorLogService.whoVisitMe(params);
        return R.ok().put("page", page);
    }


}